#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum {{ name }} {
    {% for key, value in int_code -%}
    {{ value }} = {{ key }},
    {% endfor -%}
}
impl {{ name }} {
    pub fn from(code: i32) -> {{ name }} {
        use {{ name }}::*;
        match code {
            {% for key, value in int_code -%}
            {{ key }} => {{ value }},
            {% endfor -%}
            other => panic!("Unknown {{ name }} value {}", other),
        }
    }
    {% if is_ok_val %}
    pub fn is_ok(&self) -> bool {
        *self == {{ name }}::{{ is_ok_val }}
    }
    {% endif %}
}

impl std::fmt::Display for {{ name }} {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{} - {:?}", *self as i32, self)
    }
}
